package com.xiaoma.myaudience.biz.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.xiaoma.myaudience.R;
import com.xiaoma.myaudience.biz.adapter.ActivitySelectAdapter;
import com.xiaoma.myaudience.biz.app.AudienceApplication;
import com.xiaoma.myaudience.biz.model.ActivityDetailInfoModel;
import com.xiaoma.myaudience.biz.model.ActivitySelectInfoModel;
import com.xiaoma.myaudience.biz.model.RankingListModel;
import com.xiaoma.myaudience.biz.task.ActivitySelectTask;
import com.xiaoma.myaudience.biz.task.ActivitysQuitTask;
import com.xiaoma.myaudience.biz.task.AddEventTask;
import com.xiaoma.myaudience.biz.task.DataAsyncTask;
import com.xiaoma.myaudience.biz.util.Constant;
import com.xiaoma.myaudience.biz.view.LoadingListView;
import com.xiaoma.myaudience.biz.view.RefreshableView;
import com.xiaoma.myaudience.biz.view.RefreshableView.PullToRefreshListener;
import com.xiaoma.myaudience.biz.view.wheel.OnWheelChangedListener;
import com.xiaoma.myaudience.biz.view.wheel.OnWheelScrollListener;
import com.xiaoma.myaudience.biz.view.wheel.WheelView;
import com.xiaoma.myaudience.biz.view.wheel.adapter.AbstractWheelTextAdapter;
import com.xiaoma.myaudience.util.PrefHelper;
import com.xiaoma.myaudience.util.activity.BaseActivity;
import com.xiaoma.myaudience.util.model.ModelUtils;

/**
 * 活动筛选页面
 * 
 * @author jpren
 * 
 */
public class ActivitySelectActivity extends BaseActivity implements
		OnClickListener, OnItemClickListener,PullToRefreshListener {
	private static final String TAG = "ActivitySelectActivity";
	private static final int DIALOG_ADD_EVENT = 0;
	private static final int DIALOG_ADD_EVENT_ERROR = 1;
	private static final int DIALOG_ADD_EVENT_NO_LOGIN = 2;
	private String mSizeStr;
	private String mActivityCategory;
	private String mCategoryIndex;
	private String mErrorMsg;
	private List<Map<String, Object>> mClasstMap;
	private List<Map<String, Object>> mCurrentCity;
	private ActivitysQuitTask mActivitysQuitTask;
    private int mPosition;
	private Map<String, Object> mObjMap;
	private List<Map<String, Object>> mList;


	private ActivitySelectAdapter mActivitySelectAdapter;
	private ActivitySelectTask mActivitySelectTask;
	private AddEventTask mAddEventTask;
	private String mStatus;
	private LoadingListView mLoadingListView;
	private WheelView categoryWheelView;
	private WheelView allWheelView;
	private WheelView provinceWheelView;
	private WheelView cityWheelView;
	private List<Map<String, Object>> mAllList;
    private boolean scrolling = false;
    private String[] items = {"全部", "今天", "明天", "本周" };
    private String mEventId;
	private RefreshableView mRefreshableView;
	private Map<String, String> mapcookie = null;
	
	private String mline = "0";//起始行标志
	private List<Map<String, Object>> adapterList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.main_first_page);
		mRefreshableView = (RefreshableView) findViewById(R.id.refresh_view);
        mRefreshableView.setVisibility(View.VISIBLE);
        mRefreshableView.setOnRefreshListener(this, 1);
		setNetEaseTitleBarVisibility(View.VISIBLE);
		setNetEaseTitleGravity(Gravity.CENTER);
		setNetEaseTitleBarExtra(R.layout.video_detail_extra_layout);
		setNetEaseTitle("所有");
		
		findViewById(R.id.btn_back).setOnClickListener(this);
		((Button) findViewById(R.id.show_comments_back_original)).setText("筛选");
		((Button) findViewById(R.id.show_comments_back_original)).setVisibility(View.VISIBLE);
		findViewById(R.id.show_comments_back_original).setOnClickListener(this);
		findViewById(R.id.base_title_bar_title).setOnClickListener(this);
		findViewById(R.id.checked).setOnClickListener(this);
		findViewById(R.id.checked_all).setOnClickListener(this);
		
		categoryWheelView = (WheelView) findViewById(R.id.category);
		categoryWheelView.setVisibleItems(3);
		
		mAllList = new ArrayList<Map<String,Object>>();
		for (int i = 0; i < 4; i++) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put(ActivitySelectInfoModel.PARAM_CLASSNAME, items[i]);
			mAllList.add(map);
		}
		allWheelView = (WheelView) findViewById(R.id.all);
		allWheelView.setVisibleItems(4);
		allWheelView.setViewAdapter(new CategoryAdapter(this, mAllList));
		allWheelView.setCurrentItem(0);

		provinceWheelView = (WheelView) findViewById(R.id.province);
		provinceWheelView.setVisibleItems(4);
		provinceWheelView.setViewAdapter(new CategoryAdapter(this, AudienceApplication.sProvince));
		provinceWheelView.addChangingListener(new OnWheelChangedListener() {
			
			@Override
			public void onChanged(WheelView wheel, int oldValue, int newValue) {
				if (!scrolling) {
					updateCities(provinceWheelView, AudienceApplication.sCity, 
							(String)AudienceApplication.sProvince.get(newValue).get("ID"));
				}
			}
		});
		provinceWheelView.addScrollingListener(new OnWheelScrollListener() {
			
			@Override
			public void onScrollingStarted(WheelView wheel) {
				scrolling = true;
			}
			
			@Override
			public void onScrollingFinished(WheelView wheel) {
				scrolling = false;
				updateCities(provinceWheelView, AudienceApplication.sCity, 
						(String)AudienceApplication.sProvince.get(provinceWheelView.getCurrentItem()).get("ID"));
			}
		});
		
		cityWheelView = (WheelView) findViewById(R.id.city);
		cityWheelView.setVisibleItems(4);
		cityWheelView.setViewAdapter(new CategoryAdapter(this, getDate(AudienceApplication.sCity, "0")));
		
		provinceWheelView.setCurrentItem(0);

		mLoadingListView = (LoadingListView) findViewById(R.id.hot_elv);
		//mLoadingListView.hideLoadingMoreLayout();
		//mLoadingListView.getListView().setDividerHeight(15);
		mLoadingListView.getListView().setOnItemClickListener(this);

		Bundle bundle = getIntent().getExtras();
		if (bundle != null) {
			mActivityCategory = bundle.getString(ActivitysActivity.ACTIVITY_CATEGORY);
			mCategoryIndex = bundle.getString(ActivitysActivity.ACTIVITY_CATEGORY_INDEX);
			String y = bundle.getString(ActivitysActivity.ACTIVITY_CATEGORY_INDEX_Y);
			if ("9".equals(y)) {
				mCategoryIndex = y;
			}
		}
		if (!TextUtils.isEmpty(mActivityCategory)) {
			setNetEaseTitle(mActivityCategory.substring(1, mActivityCategory.length()));
			allWheelView.setCurrentItem(0);
			
		}
		
		mapcookie = new HashMap<String, String>();
		mapcookie.put("classid", TextUtils.isEmpty(mCategoryIndex) ? "0" : mCategoryIndex);
		mapcookie.put("province", "");
		mapcookie.put("city", "");
		mapcookie.put("time", "3");
		mapcookie.put("line", mline);
		execute(mapcookie);
		
		mLoadingListView.getLoadingMoreButton().setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (!mLoadingListView.onClickDefaultMoreLayout()) {
					return;
				}
				startGetMoreTask();
			}
		});
	}
	
	private void updateCities(WheelView province, List<Map<String, Object>> map, String index) {
		
		cityWheelView.setViewAdapter(new CategoryAdapter(this, getDate(map, index)));
//		cityWheelView.setCurrentItem(list.size() / 2);        
	}
	
	private List<Map<String, Object>> getDate(List<Map<String, Object>> map, String index) {
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		for (Map<String, Object> map2 : map) {
			String id = (String) map2.get("PID");
			if (id.equals(index)) {
				list.add(map2);
			}
		}
		mCurrentCity = list;
		
		return list;
	}

	public void startGetMoreTask(){
		mapcookie = new HashMap<String, String>();
		mapcookie.put("classid", TextUtils.isEmpty(mCategoryIndex) ? "0" : mCategoryIndex);
		mapcookie.put("province", "");
		mapcookie.put("city", "");
		mapcookie.put("time", "3");
		mapcookie.put("line", mline);
		execute(mapcookie);
	}
	
	private void execute(Map<String, String> params) {
		cancel();
		mActivitySelectTask = new ActivitySelectTask(this,
				DataAsyncTask.TASK_ACTIVITY_SELECT, this);
		Map<String, String> cookie = new HashMap<String, String>();
		cookie.put(Constant.LOGIN_COOKIE1, PrefHelper.getString(
				ActivitySelectActivity.this, Constant.LOGIN_COOKIE1, ""));
		cookie.put(Constant.LOGIN_COOKIE2, PrefHelper.getString(
				ActivitySelectActivity.this, Constant.LOGIN_COOKIE2, ""));
		cookie.put("url", mActivityCategory);
		cookie.putAll(params);
		mActivitySelectTask.execute(cookie);
	}

	private void cancel() {
		if (mActivitySelectTask != null) {
			mActivitySelectTask.cancel(true, true);
		}
		mActivitySelectTask = null;
	}

	private void addEvent() {
		if (mAddEventTask != null) {
			mAddEventTask.cancel(true, true);
		}
		mAddEventTask = null;

		mAddEventTask = new AddEventTask(this, DataAsyncTask.TASK_ADD_EVENT,
				this);
		Map<String, String> cookie = new HashMap<String, String>();
		cookie.put(Constant.LOGIN_COOKIE1, PrefHelper.getString(
				ActivitySelectActivity.this, Constant.LOGIN_COOKIE1, ""));
		cookie.put(Constant.LOGIN_COOKIE2, PrefHelper.getString(
				ActivitySelectActivity.this, Constant.LOGIN_COOKIE2, ""));
		cookie.put("url", mEventId);
		mAddEventTask.execute(cookie);
	}

	private void addEventPorcess(Map<String, Object> map) {
		if (!"0".equals(ModelUtils.getStringValue(map, "code"))) {
			mErrorMsg = ModelUtils.getStringValue(map, "errorMsg");
			showDialog(DIALOG_ADD_EVENT_ERROR);
		} else {
			//弹出信息
			Map<String, Object> data = ModelUtils.getMapValue(map, "data");
			String nengLiang = ModelUtils.getStringValue(data, "nengliang");
			int i = Integer.valueOf(nengLiang);
			mErrorMsg = (i > 0 ? "参加成功，奖励" + i : "参加成功，消耗" + Math.abs(i)) + "能量";
			
			boolean verify = ModelUtils.getStringValue(mObjMap, RankingListModel.PARAM_VERIFY).equals("1")? true : false;
			mList.remove(mPosition);
			mObjMap.put(RankingListModel.PARAM_STATUS, verify ? "3" : "4");
			mList.add(mPosition, mObjMap);
			mActivitySelectAdapter.notifyDataSetChanged();
			
			removeDialog(DIALOG_ADD_EVENT_ERROR);
			showDialog(DIALOG_ADD_EVENT_ERROR);
			showDialog(DIALOG_ADD_EVENT_ERROR);
		}
	}
	
	private void quitEventProcess(Map<String, Object> objMap) {
		if (!"0".equals(ModelUtils.getStringValue(objMap, "code"))) {
			mErrorMsg = ModelUtils.getStringValue(objMap, "errorMsg");
			showDialog(DIALOG_ADD_EVENT_ERROR);
		} else {
			//弹出信息
			mErrorMsg = "退出成功";
			mList.remove(mPosition);
			mObjMap.put(RankingListModel.PARAM_STATUS, "0");
			mList.add(mPosition, mObjMap);
			mActivitySelectAdapter.notifyDataSetChanged();
			removeDialog(DIALOG_ADD_EVENT_ERROR);
			showDialog(DIALOG_ADD_EVENT_ERROR);
		}
	}

		
	@Override
	public void onPostExecute(int what, Object o) {
		mRefreshableView.finishRefreshing();
		super.onPostExecute(what, o);
		Map<String, Object> objMap = (Map<String, Object>) o;
		switch (what) {
		case DataAsyncTask.TASK_ACTIVITY_SELECT:
			if (objMap == null || objMap.size()<1) {
				mLoadingListView.hideLoadingMoreLayout();
				return;
			}
			mLoadingListView.finishClickDefaultMoreLayout();
			initData(objMap);
			break;

		case DataAsyncTask.TASK_ADD_EVENT:
			addEventPorcess(objMap);
			break;
			
		case DataAsyncTask.TASK_QUIT_EVENT:
    		Map<String, Object> map = (Map<String, Object>) o;
			quitEventProcess(map);
			break;	

		default:
			break;
		}
	}

	private void initData(Map<String, Object> objMap) {
		if(adapterList==null){
			adapterList = new ArrayList<Map<String, Object>>();
		}
		
		if(objMap==null){
			Tips("没有数据");
			mLoadingListView.hideLoadingMoreLayout();
			return;
		}
		List<Map<String, Object>> list = ModelUtils.getListMapValue(objMap,
				ActivitySelectInfoModel.PARAM_EVENTS);
		mList = list;
		if(list.size()==0){
			Tips("没有数据");
			mLoadingListView.hideLoadingMoreLayout();
			return;
		}
		adapterList.addAll(list);
		if(mActivitySelectAdapter==null){
			mActivitySelectAdapter = new ActivitySelectAdapter(this, adapterList);	
			mLoadingListView.getListView().setAdapter(mActivitySelectAdapter);
			mLoadingListView.getListView().setOnItemClickListener(this);
		}
		mActivitySelectAdapter.notifyDataSetChanged();
		//获取最后一条数据的dateline
		this.mline = (String)list.get(list.size()-1).get("dateline");
		mClasstMap = ModelUtils.getListMapValue(objMap, ActivitySelectInfoModel.PARAM_CLASS);
		String currentclassid = ModelUtils.getStringValue(objMap, "currentclassid");
		categoryWheelView.setViewAdapter(new CategoryAdapter(this, mClasstMap));
		int index = 0;
		if(!TextUtils.isEmpty(mCategoryIndex)) {
			index = "9".equals(mCategoryIndex) ? 6 : Integer.valueOf(mCategoryIndex);
		}
		if(mActivityCategory.length()<2){return;}
		String classname = mActivityCategory.substring(1, mActivityCategory.length()).trim();
		HashMap<String, String> a =new HashMap<String, String>();
		a.put("classid",currentclassid);
		a.put("classname", classname);
		categoryWheelView.setCurrentItem(mClasstMap.indexOf(a));
		categoryWheelView.addChangingListener(new OnWheelChangedListener() {
			
			@Override
			public void onChanged(WheelView wheel, int oldValue, int newValue) {
				
			}
		});
		categoryWheelView.addScrollingListener(new OnWheelScrollListener() {
			
			@Override
			public void onScrollingStarted(WheelView wheel) {
				scrolling = true;
			}
			
			@Override
			public void onScrollingFinished(WheelView wheel) {
				scrolling = false;
			}
		});
	}

	@Override
	protected Dialog onCreateDialog(int id) {
		switch (id) {

		 case DIALOG_ADD_EVENT: {
             AlertDialog.Builder builder = new Builder(ActivitySelectActivity.this);
             builder.setPositiveButton(R.string.add_event_ok, new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                 	Intent intent = new Intent(ActivitySelectActivity.this, UserInfoDetailActivity.class);
                 	ActivitySelectActivity.this.startActivity(intent);
                 }
             }).
             setNegativeButton(R.string.add_event_cancel, new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                 	
                 }
             }).setMessage(R.string.add_event_msg);
             return builder.create();
         }
         
         case DIALOG_ADD_EVENT_NO_LOGIN: {
         	AlertDialog.Builder builder = new Builder(ActivitySelectActivity.this);
         	builder.setMessage(R.string.login_please);
         	builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						Intent intent= new Intent(ActivitySelectActivity.this, LoginActivity.class);
						ActivitySelectActivity.this.startActivity(intent);
					}
         	});
         	return builder.create();
         }
         
         case DIALOG_ADD_EVENT_ERROR: {
         	AlertDialog.Builder builder = new Builder(ActivitySelectActivity.this);
         	builder.setNegativeButton(R.string.add_event_ok, new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                 	
                 }
         	});
         	builder.setMessage(mErrorMsg);
         	return builder.create();
         }
     }
     return super.onCreateDialog(id);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_back:
			ActivitySelectActivity.this.finish();
			break;

		case R.id.activity_tip:
			break;

		case R.id.show_comments_back_original:
			//筛选
			if (mClasstMap != null && mClasstMap.size() > 0) {
				findViewById(R.id.selected).setVisibility(View.VISIBLE);
				findViewById(R.id.all_category).setVisibility(View.GONE);
			}
			break;
		case R.id.checked_all:{
			//筛选
			findViewById(R.id.selected).setVisibility(View.GONE);
			int time = allWheelView.getCurrentItem()+1;
			int province = provinceWheelView.getCurrentItem();
			String provinceStr = province == 0 ? "" : (String) AudienceApplication.sProvince.get(province).get(ActivitySelectInfoModel.PARAM_CLASSNAME);
			int city = cityWheelView.getCurrentItem();
			String cityStr = city == 0 ? "" : (String) mCurrentCity.get(city).get(ActivitySelectInfoModel.PARAM_CLASSNAME);
			
			
			//发送请求
			mapcookie = new HashMap<String, String>();
			mapcookie.put("classid", String.valueOf(mCategoryIndex));
			mapcookie.put("province", provinceStr);
			mapcookie.put("city", cityStr);
			mapcookie.put("line", mline);
			//针对于界面上“全部”和真实值不对应，需要进行调整，
			if(time==1 || time==3){
				mapcookie.put("time", (time==3?1:3) + "");
			}else{
				mapcookie.put("time", time + "");
			}
			execute(mapcookie);
		}
			break;
		case R.id.base_title_bar_title:
			//类别
			if (mClasstMap != null && mClasstMap.size() > 0) {
				findViewById(R.id.all_category).setVisibility(View.VISIBLE);
				findViewById(R.id.selected).setVisibility(View.GONE);
			}
			break;
		case R.id.checked: {
			//隐藏取数据
			findViewById(R.id.all_category).setVisibility(View.GONE);
			int index = categoryWheelView.getCurrentItem();
			mCategoryIndex = String.valueOf(index);
			String currentItem = ModelUtils.getStringValue(mClasstMap.get(index), ActivitySelectInfoModel.PARAM_CLASSNAME);
			((TextView)findViewById(R.id.base_title_bar_title)).setText(currentItem);
			String currentclassid = ModelUtils.getStringValue(mClasstMap.get(index), ActivitySelectInfoModel.PARAM_CLASS_ID);
			
			//发起网络请求
			mapcookie = new HashMap<String, String>();
			mapcookie.put("classid", currentclassid);
			mapcookie.put("province", "");
			mapcookie.put("city", "");
			mapcookie.put("time", "3");
			mapcookie.put("line", mline);
			execute(mapcookie);
		}
			break;

		default:
			break;
		}
	}
	
	private void executeQuit() {
		cancelQuit();
		mActivitysQuitTask = new ActivitysQuitTask(this, DataAsyncTask.TASK_QUIT_EVENT, this);
		Map<String,String> cookie = new HashMap<String,String>();
		cookie.put(Constant.LOGIN_COOKIE1,PrefHelper.getString(ActivitySelectActivity.this,Constant.LOGIN_COOKIE1,""));
		cookie.put(Constant.LOGIN_COOKIE2,PrefHelper.getString(ActivitySelectActivity.this,Constant.LOGIN_COOKIE2,""));
		cookie.put("url", mEventId);
		mActivitysQuitTask.execute(cookie);
	}
	
	private void cancelQuit() {
		if (mActivitysQuitTask != null) {
			mActivitysQuitTask.cancel(true, true);
		}
		mActivitysQuitTask = null;
	}

	@Override
	public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
		Map<String, Object> item = (Map<String, Object>) adapter.getItemAtPosition(position);
		mPosition = position;
		mEventId = ModelUtils.getStringValue(item, ActivityDetailInfoModel.PARAM_EVENTID);
		mObjMap = item;
    	if (item != null) {
			String status = ModelUtils.getStringValue(item, ActivityDetailInfoModel.PARAM_STATUS);
			Boolean islogin = PrefHelper.getBoolean(ActivitySelectActivity.this, Constant.LOGIN_ISLOGIN, false);
			if ("0".equals(status)) {
	    		mEventId = ModelUtils.getStringValue(item, ActivityDetailInfoModel.PARAM_EVENTID);
		  		if (islogin) {
		  			//已登录都给丫显示
		  			showAddInfoDialog(R.string.add_event_txt);
		  			return;
				} else {
					showDialog(DIALOG_ADD_EVENT_NO_LOGIN);
				}
			} else if ("3".equals(status) || "4".equals(status)) {
				if (islogin) {
					executeQuit();
				} else {
					showDialog(DIALOG_ADD_EVENT_NO_LOGIN);
				}
			}
		}
    	if(v.getId()==mLoadingListView.getId()){
    		startGetMoreTask();
    	}
	}
	
	private void showAddInfoDialog(final int string) {
		final Dialog dlg = new AlertDialog.Builder(ActivitySelectActivity.this).create();
		 Window window = dlg.getWindow();
		 dlg.show();
		 window.setContentView(R.layout.add_event_view_layout);
		 if (string == R.string.add_event_txt) {
			 ((TextView)window.findViewById(R.id.base_title_bar_title)).setText(R.string.add_event_title_xy);
		 }else {
			((TextView)window.findViewById(R.id.base_title_bar_title)).setText(R.string.activity_detail);
		 }
		 
		 View vcancel = window.findViewById(R.id.cancel_comments_back_original);
		 vcancel.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					dlg.dismiss();
				}
		 });
		 
		 window.findViewById(R.id.show_comments_back_original).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				dlg.dismiss();
				if(string == R.string.add_event_txt) {
					//必填资料需填写
		  			if (!PrefHelper.getBoolean(ActivitySelectActivity.this, "isfulluserinfo", false)) {
		  				showDialog(DIALOG_ADD_EVENT);
					} else {
						//资料都全，参加活动
						addEvent();
					}
				}
			}
		});
	}
	
	private class CategoryAdapter extends AbstractWheelTextAdapter {
		private List<Map<String, Object>> mList;
		
		protected CategoryAdapter (Context context, List<Map<String, Object>> list) {
			super(context, R.layout.category_layout, NO_RESOURCE);
			mList = list;
			setItemTextResource(R.id.country_name);
		}

		@Override
		public int getItemsCount() {
			return mList.size();
		}
		
		@Override
		protected CharSequence getItemText(int index) {
			return ModelUtils.getStringValue(mList.get(index), ActivitySelectInfoModel.PARAM_CLASSNAME);
		}
	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub
		mapcookie = new HashMap<String, String>();
		mapcookie.put("classid", TextUtils.isEmpty(mCategoryIndex) ? "0" : mCategoryIndex);
		mapcookie.put("province", "");
		mapcookie.put("city", "");
		mapcookie.put("time", "3");
		execute(mapcookie);
	}
}